<extend name="Public:base"/>

<!--侧边导航-->
<block name="aside">
    <include file="Public:aside"/>
</block>

<block name="main">
<script type="text/javascript" src="__JS__/preview.js"></script>
<style>
#preview{
    position:absolute;
    border:1px solid #ccc;
    background:#333;
    padding:5px;
    display:none;
    color:#fff;
}
#preview img{width:200px;height:200px;}
</style>

<div class="table-toolbar">
    <div class="row">
        <div class="col-md-12">
            <a href="{:U($model_name.'/add')}" class="btn btn-sm btn-primary">添加</a>
            <a class="btn btn-sm btn-primary" onclick="return confirm_deleteall()">删除</a>
            <a class="btn btn-sm btn-primary" onclick="myform.action='{:U($model_name.'/listorder')}';$('#myform').submit();" >排序</a>
            <a class="btn btn-sm btn-primary" onclick="content_check();" >审核</a>
            <a class="btn btn-sm btn-primary" onclick="content_nocheck();">取消审核</a>
            <a class="btn btn-sm btn-primary" id="push_btn">推送</a>
            <a class="btn btn-sm btn-primary" id="content_move" >批量移动</a>
        </div>
    </div>
</div>

<div class="table-toolbar">
    <div class="row">
        <div class="col-md-12">
            <form class="form-inline" action="{:U($model_name.'/index')}" method="get">
                <input type="hidden" name="g" value="{$Think.GROUP_NAME}" />
                <input type="hidden" name="m" value="{$Think.MODULE_NAME}" />
                <input type="hidden" name="a" value="{$Think.ACTION_NAME}" />

                <div class="form-group">
                    <input type="text" class="form-control" name="keyword" value="{$keyword}" />
                </div>
                <div class="form-group">
                    <select class="form-control" name="searchtype">
                        <if condition="$fields['title']"><option value="title" <eq name="searchtype" value='title'>selected="selected"</eq>>标题</option></if>
                        <if condition="$fields['keywords']"><option value="keywords" <eq  name="searchtype" value='keywords'>selected="selected"</eq>>关键词</option></if>
                        <option value="id" <eq name="searchtype" value='id'>selected="selected"</eq>>ID</option>
                    </select>
                </div>

                <div class="form-group">
                    <if condition="$fields['catid']">
                        <select class="form-control" id="catid" name="catid">
                            <option value="0">选择栏目</option>
                            {$select_categorys}
                        </select>
                    </if>
                </div>

                <div class="form-group">
                    <select class="form-control" id="status" name="map[status]">
                        <option value="">{:L('status')}</option>
                        <option value="0" <if condition="isset($status) && $status ==0">selected="selected"</if>>未审核</option>
                        <option value="1" <if condition="isset($status) && $status ==1">selected="selected"</if>>已审核</option>
                    </select>
                </div>
                <div class="form-group">
                    <select class="form-control" id="order" name="order">
                        <option value="listorder" <eq name="order" value="listorder">selected="selected"</eq>>排序</option>
                        <option value="id" <eq name="order" value="id">selected="selected"</eq>>ID排序</option>
                        <if condition="$fields['hits']"><option value="hits" <eq name="order" value="hits">selected="selected"</eq>>{:L('hits')}排序</option></if>
                    </select>
                </div>
                <div class="form-group">
                    <select class="form-control" name="sort">
                        <option value="asc" <if condition="$sort =='asc'">selected="selected"</if>>递增</option>
                        <option value="desc" <if condition="$sort =='desc'">selected="selected"</if>>递减</option>
                    </select>
                </div>
                <div class="form-group">
                    <select class="form-control" name="listRows">
                        <option value="15" <if condition="$listRows ==5">selected="selected"</if>>15条每页</option>
                        <option value="20" <if condition="$listRows ==20">selected="selected"</if>>20条每页</option>
                        <option value="50" <if condition="$listRows ==50">selected="selected"</if>>50条每页</option>
                        <option value="100" <if condition="$listRows ==100">selected="selected"</if>>100条每页</option>
                    </select>
                </div>
                <input type="submit" value="查询"  class="btn btn-primary" />
            </form>

        </div>
    </div>
</div>

<div class="row table-container">
    <div class="col-md-12">
        <form name="myform" id="myform" action="" method="post">

            <table class="table table-hover table-bordered">
                <thead>
                <tr>
                    <th class="w-50"><input type="checkbox" value="" id="check_box" onclick="selectall('ids[]');"></th>
                    <th class="w-50">{:L('listorder')}</th>
                    <th width="40">ID</th>
                    <th>标题</th>
                    <th>日期</th>
                    <if condition="$fields['status']"><th width="60">状态</th> </if>
                    <th width="60">发布人</th>
                    <th class="center table-cell-2">操作管理</th>
                </tr>
                </thead>
                <tbody>
                <empty name="list">
                    <tr class="table-data-empty">
                        <td class="text-center empty-info" colspan="8">
                            <i class="fa fa-database"></i> 暂时没有数据<br>
                        </td>
                    </tr>
                <else/>
                <volist name="list" id="vo" key="k">
                    <tr>
                        <td width="30" align="center">
                            <input class="inputcheckbox" name="ids[]" value="{$vo['id']}" type="checkbox">
                        </td>
                        <td width="40" align='center'>
                            <input name='listorders[{$vo.id}]' type='text' size='3' value='{$vo.listorder}' class='input-text-c'>
                        </td>
                        <td align="center">{$vo['id']}</td>
                        <td>
                            <if condition="$vo['catid']">[<font color="green">{$categorys[$vo['catid']]['catname']}</font>]</if>
                            <a href="{$vo.url}" <if condition="$vo['title_style']!=''">style ="{$vo['title_style']}"</if> target="_blank">{$vo['title']} </a>
                            <if condition="$vo['thumb']!=''"><a href="{$vo['thumb']}" class="preview" title="{$vo['title']}"><img src="__IMG__/admin_image.gif"></a></if>
                            <if condition="$vo['posid']!=0">
                                <img src="__IMG__/admin_elite.gif">
                            </if>
                        </td>
                        <td>
                            {$vo['createtime']|toDate=###,'Y-m-d'}
                            <?php if($vo['createtime'] >= time()){?>
                                定时发布
                            <?php } else { ?>
                                已发布
                            <?php }?>
                        </td>
                        <if condition="$fields['status']">
                            <td align="center">
                                {if $vo['status']==1}
                                <font color="green">已审核</font>
                                {else}
                                <a href="{:U($model_name.'/status',array(id=>$vo['id'],status=>1))}"><font color="red">未审核</font></a>
                                {/if}
                            </td>
                        </if>
                        <td align="center">{$vo['username']}</td>
                        <td class="center table-cell-2">
                            <a class="btn btn-xs btn-primary" href="{:U($model_name.'/edit',array('id'=>$vo['id']))}">编辑</a>
                            <a class="btn btn-xs btn-danger" href="javascript:confirm_delete('{:U($model_name.'/delete',array('id'=>$vo['id']))}')">删除</a>
                        </td>
                    </tr>
                </volist>
                </empty>
                </tbody>
            </table>

            <div class="row">
                <div class="col-md-12">
                    <div class="pull-left" style="margin:20px 0;">

                    </div>
                    <div class="pull-right pagination">{$page}</div>
                </div>

            </div>
        </form>
    </div>
</div>
</block>

<block name="script">
<script>
$("#catid").val({$catid});

function confirm_deleteall(){
    var str = 0;
    var id = tag = '';
    $('input[name="ids[]"]:checked').each(function(){
        str = 1;
        id += tag + $(this).val();
        tag = ',';
    });
    if (str == 0) {
        layer.msg('您没有勾选信息，无法进行操作！', {
            icon: 2,
            time: 1000 //2秒关闭（如果不配置，默认是3秒）
        });
        return false;
    }
    layer.confirm("{:L('real_delete')}", function(){
        myform.action = '/?m={$model_name}&g=admin&a=delete&id='+id;
        $('#myform').submit();
    });
}

function content_check(){
    var str = 0;
    var id = tag = '';
    $('input[name="ids[]"]:checked').each(function(){
        str = 1;
        id += tag + $(this).val();
        tag = ',';
    });
    if (str == 0) {
        layer.msg('您没有勾选信息，无法进行操作！', {
            icon: 2,
            time: 1000 //2秒关闭（如果不配置，默认是3秒）
        });
        return false;
    }
    $.ajax({
        url:'/?m={$model_name}&g=admin&a=public_check&id='+id,
        beforeSend:function(){
            layer.msg('审核中');
        },
        success:function(data){
            window.location.reload();
        }
    });
}
function content_nocheck(){
    var str = 0;
    var id = tag = '';
    $('input[name="ids[]"]:checked').each(function(){
        str = 1;
        id += tag + $(this).val();
        tag = ',';
    });
    if (str == 0) {
        layer.msg('您没有勾选信息，无法进行操作！', {
            icon: 2,
            time: 1000 //2秒关闭（如果不配置，默认是3秒）
        });
        return false;
    }
    $.ajax({
        url:'/?m={$model_name}&g=admin&a=public_nocheck&id='+id,
        beforeSend:function(){
            layer.msg('取消审核中');
        },
        success:function(data){
            window.location.reload();
        }
    });
}

$('#push_btn').click(function(){
    var str = 0;
    var id = tag = '';
    $('input[name="ids[]"]:checked').each(function(){
            str = 1;
            id += tag + $(this).val();
            tag = '|';
    });
    if (str == 0) {
        layer.msg('您没有勾选信息，无法进行操作！', {
            icon: 2,
            time: 1000 //2秒关闭（如果不配置，默认是3秒）
        });
        return false;
    }
    openwin('/?m={$model_name}&g=admin&a=push&action=position_list&modelid={$modelid}&id=' + id,'信息推送','800px','400px');
});

$('#content_move').click(function(){
    var str = 0;
    var id = tag = '';
    $('input[name="ids[]"]:checked').each(function(){
            str = 1;
            id += tag + $(this).val();
            tag = '|';
    });
    if (str == 0) {
        layer.msg('您没有勾选信息，无法进行操作！', {
            icon: 2,
            time: 1000 //2秒关闭（如果不配置，默认是3秒）
        });
        return false;
    }
    openwin('/?m={$model_name}&g=admin&a=remove&modelid={$modelid}&id=' + id,'批量移动','800px','400px');
});

</script>
</block>